package cc.lucien.Controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;

/**
 * @author lucien-ma
 * @date 2021/9/7
 * @apiNote
 */
@Controller
@RequestMapping("/rest")
public class RESTHandler {

    //@RequestMapping(value = "/find", method = RequestMethod.GET)
    @GetMapping("/find")   // 等同于上面的，RESTful 规范
    @ResponseBody
    public String find() {
        return "hello";
    }

    @PostMapping("/save")
    public void save() {

    }

    @PutMapping("/update")
    @ResponseBody
    public String update(HttpServletResponse response) {
        response.setCharacterEncoding("UTF-8");
        return "接收到一个 PUT 请求";
    }

    @DeleteMapping("/delte")
    @ResponseBody
    public String delete(HttpServletResponse response) {
        response.setCharacterEncoding("UTF-8");
        return "接收到一个 DELETE 请求";
    }
}
